import axios from 'axios'

// 给axios设置一些默认行为
switch (process.env.NODE_ENV) {
    case 'production':
        axios.defaults.baseURL = 'https://service-6iqgsqxy-1251958066.gz.apigw.tencentcs.com/release/';
        break;
    case 'development':
        axios.defaults.baseURL = 'https://service-6iqgsqxy-1251958066.gz.apigw.tencentcs.com/release/';
        break;
}

// 设置超时时间
axios.defaults.timeout = 10000;
// 设置跨域是否需要携带凭证
axios.defaults.withCredentials = true


// // 设置请求之前的拦截器
axios.interceptors.request.use(config => {
    // localStorage.getItem('cookie') && (config.headers.Authorization = localStorage.getItem('cookie'))
    return config;
})


// // 设置响应之后的拦截器
axios.interceptors.response.use(response => {
    return response?.data;
})

export default axios